package producatorconsumator;

import java.util.Stack;

public class BlockMyStack {

	Stack<String> myStack = new Stack<String>();
	String stackValue;

	public synchronized void push(String s) {

		myStack.push(s);

		notify();

	}

	public synchronized void pop() throws InterruptedException {

		while (myStack.isEmpty()) {
			wait();

		}
		setStackValue(myStack.peek());
		myStack.pop();

	}

	public String getStackValue() {
		return stackValue;
	}

	public void setStackValue(String stackValue) {
		this.stackValue = stackValue;
	}

}
